import os
from urllib.parse import quote_plus

# app文件夹目录
app_dir_path = os.path.abspath(os.path.dirname(__file__))

# app文件夹的上级目录
prod_dir_path = os.path.abspath(os.path.join(app_dir_path, os.pardir))


class Config:
    DEBUG = False
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'your secret'

    # MySQL数据库配置
    MYSQL_HOST = os.environ.get('MYSQL_HOST') or 'xxx.xxx.xxx.xxx'
    MYSQL_PORT = int(os.environ.get('MYSQL_PORT') or 3306)
    MYSQL_USER = os.environ.get('MYSQL_USER') or 'root'
    MYSQL_PASSWORD = os.environ.get('MYSQL_PASSWORD') or 'your password'
    MYSQL_DB = os.environ.get('MYSQL_DB') or 'youre db name'

    # PyMySQL库配置
    SQLALCHEMY_DATABASE_URI = f"mysql+pymysql://{MYSQL_USER}:{quote_plus(MYSQL_PASSWORD)}@{MYSQL_HOST}:{MYSQL_PORT}/{MYSQL_DB}?charset=utf8mb4"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    UPLOAD_FOLDER = '%s/static/uploads' % prod_dir_path
    INFO_FOLDER = '%s/static/info' % prod_dir_path
    FIELD_DICT_FILE = os.path.join(INFO_FOLDER, "数据库原始数据字典.xlsx")
    PROCSSED_FIELD_DICT_FILE = os.path.join(INFO_FOLDER, "加工报表数据字典.xlsx")
    PINXIANG_XLSX_TEMPLATE_FILE = os.path.join(INFO_FOLDER, "产品结构与折扣.xlsx")
